var minJumps = function(arr) {
    let used = {}
    let cache = {}
    arr.forEach((item, index) => {
        used[index] = false
        if (cache[item]) {
            cache[item].push(index)
        } else {
            cache[item] = [index]
        }
    });
    let findFlag = false
    let jumpCount = 0
    let findArr = [0]
    while (!findFlag) {
        let tempArr = []
        for (let i = 0; i < findArr.length; i++) {
            const index = findArr[i];
            if (index === arr.length - 1) {
                findFlag = true
                return jumpCount;
            }
            if (used[index]) {
                continue
            } else {
                used[index] = true
            }
            index > 0 && !used[index - 1] ? tempArr.push(index - 1) : null
            index < arr.length - 1 && !used[index + 1] ? tempArr.push(index + 1) : null
            for (let j = 0; j < cache[arr[index]].length; j++) {
                const item = cache[arr[index]][j];
                !used[item] ? tempArr.push(item) : null
            }
            cache[arr[index]] = []
        }
        findArr = tempArr
        jumpCount++
    }
    return jumpCount
};
console.log(minJumps([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 11]))